home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / RESOURCE / JKMRES.GOO / cog_force_absorb.cog < prev    next >
Text File  |  1998-02-25  |  5KB  |  190 lines

  1. # Jedi Knight Cog Script
  2. #
  3. # FORCE_ABSORB.COG
  4. #
  5. # FORCEPOWER Script - Absorb
  6. #  Light Side Power
  7. #  Bin 28
  8. #
  9. # [YB]
  10. #
  11. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  12.  
  13.  
  14. symbols
  15.  
  16. thing       player                           local
  17.  
  18. flex        mana                             local
  19. flex        cost=200.0                       local
  20. flex        damage                           local
  21. flex        type                             local
  22. flex        absorb                           local
  23.  
  24. int         absorbFlags=8                    local
  25. int         rank                             local
  26.  
  27. sound       absorbSound2=ForceAbsorb02.WAV   local
  28.  
  29. template    sphere_tpl=+force_heal           local
  30. int         sphere=-1                        local
  31. vector      position                         local
  32.  
  33. flex        absorption=0.0                   local
  34. int         allowfx=1                        local
  35.  
  36. int         inbubble=0                       local
  37.  
  38. message     startup
  39. message     damaged
  40. message     activated
  41. message     timer
  42. message     pulse
  43. message     newplayer
  44. message     killed
  45. message     selected
  46. message     enterbubble
  47. message     exitbubble
  48.  
  49. end
  50.  
  51. # ========================================================================================
  52.  
  53. code
  54.  
  55. startup:
  56.    player = GetLocalPlayerThing();
  57.    inbubble = 0;
  58.    call stop_power;
  59.  
  60.    Return;
  61.  
  62. # ........................................................................................
  63.  
  64. damaged:
  65.    damage = GetParam(0);
  66.  
  67.    if(IsInvActivated(player, 28))
  68.    {
  69.       // If damage from magic
  70.       type = GetParam(1);
  71.       if(BitTest(absorbFlags, type))
  72.       {
  73.          AddDynamicTint(player, 0, 0, damage/100);
  74.          PlaySoundThing(absorbSound2, player, 1.0, -1, -1, 0x80);
  75.  
  76.          if(allowfx)
  77.          {
  78.             // Add some visual effects, but not too often
  79.             allowfx = 0;
  80.             SetTimerEx(1, 2, 0, 0);
  81.             sphere = CreateThingAtPosNR(sphere_tpl, GetThingSector(player), GetThingPos(player), '0.0 0.0 0.0');
  82.             AttachThingToThingEx(sphere, player, 0x8);
  83.             SetParticleGrowthSpeed(sphere, -0.8);
  84.             SetLifeLeft(sphere, 0.5);
  85.          }
  86.  
  87.          rank = GetInv(player, 28);
  88.          absorption = rank / 4;
  89.  
  90.          // Convert part of the damage to mana.
  91.          ChangeInv(player, 14, damage * absorption);
  92.          damage = damage * (1-absorption);
  93.       }
  94.    }
  95.  
  96.    ReturnEx(damage);
  97.    Return;
  98.  
  99. # ........................................................................................
  100.  
  101. activated:
  102.    if(!IsInvActivated(player, 28))
  103.    {
  104.       mana = GetInv(player, 14);
  105.       if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
  106.       {
  107.          if(GetInv(player, 64) != 1) ChangeInv(player, 14, -cost);
  108.          SetInvActivated(player, 28, 1);
  109.  
  110.          PlayMode(player, 24);
  111.  
  112.          //PlaySoundThing(absorbSound, player, 1.0, -1, -1, 0x80);
  113.          rank = GetInv(player, 28);
  114.          SetTimerEx(rank * 5, 1, 0, 0);
  115.          SetPulse(0.5);
  116.  
  117.          // Send a "force disturbance"...
  118.          if(!IsMulti())
  119.             SendMessageExRadius(GetThingPos(player), cost, 0x4, splash, 28, 0, 0, 0);
  120.       }
  121.    }
  122.  
  123.    Return;
  124.  
  125. # ........................................................................................
  126.  
  127. timer:
  128.  
  129.    if(GetSenderId() == 1)
  130.    {
  131.       call stop_power;
  132.    }
  133.    else
  134.    if(GetSenderId() == 2)
  135.    {
  136.       allowfx = 1;
  137.    }
  138.  
  139.  
  140.    Return;
  141.  
  142. # ........................................................................................
  143.  
  144. pulse:
  145.    // check that the player didn't die
  146.    if(GetThingHealth(player) < 1) call stop_power;
  147.  
  148.    Return;
  149.  
  150. # ........................................................................................
  151.  
  152. selected:
  153.    jkPrintUNIString(player, 28);
  154.    Return;
  155.  
  156. # ........................................................................................
  157.  
  158. killed:
  159.    if(GetSenderRef() != player) Return;
  160.  
  161. newplayer:
  162.    call stop_power;
  163.  
  164.    Return;
  165.  
  166. # ........................................................................................
  167.  
  168. enterbubble:
  169.    inbubble = 1;
  170.    call stop_power;
  171.    Return;
  172.  
  173. # ........................................................................................
  174.  
  175. exitbubble:
  176.    inbubble = 0;
  177.    Return;
  178.  
  179. # ........................................................................................
  180.  
  181. stop_power:
  182.    SetPulse(0);
  183.    KillTimerEx(1);
  184.    SetInvActivated(player, 28, 0);
  185.  
  186.    Return;
  187.  
  188. end
  189.  
  190.